package net.dopan.pigframe.core.redis.utils;

import java.util.LinkedList;
import java.util.List;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import org.springframework.stereotype.Component;
import redis.clients.jedis.*;

/**
 * @author wufeihong
 * redis
 */
@Component
public class RedisUtils {
    public static ShardedJedisPool pool;
    static {

        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(100);
        config.setMaxIdle(50);
        config.setMaxWaitMillis(3000);
        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);
        // 集群
        JedisShardInfo jedisShardInfo1 = new JedisShardInfo("101.132.171.102", 6379);
        jedisShardInfo1.setPassword("pigframe");
        List<JedisShardInfo> list = new LinkedList<JedisShardInfo>();
        list.add(jedisShardInfo1);
        pool = new ShardedJedisPool(config, list);
    }


    public static void main(String[] args) {
//        System.err.println("accessKeyId"+config.getProperty("server.port","出错了!"));

        ShardedJedis jedis = RedisUtils.pool.getResource();
//        ShardedJedis jedis = pool.getResource();
        String keys = "KKKKKKK";
        jedis.set(keys, "大家好才是真的好");
        System.out.println(jedis.get("KKKKKKK")+";;;;;;;;;;;;;;;;;;;;;;;;;");
        jedis.del(keys);
        System.out.println(jedis.get("KKKKKKK")+";;;;;;;;;;;;;;;;;;;;;;;;;");
        System.err.println("--------------------------------");
    }
}